package com.anli.web;

import com.anli.xianliu.XianLiuAnn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * @author: LI-CI-GAO
 * 作者: licigao
 * 日期: 2021/8/30  9:50
 * 描述:
 */
@RestController
public class XianliuTestController {

    private UUID uuid=UUID.randomUUID();

    @Autowired
    @Qualifier("redisTemplate10")
    private RedisTemplate<String,String> redisTemplate;

    @RequestMapping("xianliu")
    @XianLiuAnn(key = "xianLiuTest",limitRate = "10",expireKey = "2")
    public String xianLiuTest(){

        System.out.println("========================");

        return "OK";
    }


    @RequestMapping("xianliu02")
    public String xianLiuTest02(){

        System.out.println("========================");

        String replace = uuid.toString().replace("-", "");

        redisTemplate.opsForValue().set(replace,"");

        redisTemplate.expire(replace,10,TimeUnit.SECONDS);

        return "OK";
    }

}
